FSI API: Image panel

Clear image

fsi.clearImagePanel('<control id>'); Removes the current image or document from the named image panel.

Validate image file

fsi.validateImageFile('<control id>'); Returns true if a valid image file has been selected in the named image panel. Returns false if no file has been selected, or the file is not a supported image file.

Get image base64 data

fsi.getById('<control id>'); For image files only; returns a base64 string representing the image selected in the image panel.

The actual string returned depends on the setting of Properties > Data > Type in the page designer as follows:

Type: Image returns a full data URL:

[data:<media type>;base64,<base64 string>]

you could then use a JavaScript String split() method to extract just the base64 string if needed.

Type: Document returns just:

[<base64 string>]

Setting an image panel using JavaScript

In JavaScript, you can use fsi.setById() with an array to set an image in an image panel; the image can then be saved in a data object.

The array specifies the image base64 data, the base64 data length, and a filename—

{Content: "<base64 string>", Length: <base64 string length>, FileName: "<filename>"}

Example

This example builds a file name based on the current date and time.

function setImagePanel(){
    var image = {};
    image.Content = base64Image;
    image.FileName = new Date().getTime() + 'A.jpeg';
    image.Length = base64Image.length;
    fsi.setById('imagepanel-k4hS', image);
    }

For information about taking pictures with a mobile device for display in an image panel, see FSI API: Mobile Devices.

ArrayBuffer to Base64

fsi.base64ArrayBuffer(<arrayBuffer>) Returns a Base64 string from an ArrayBuffer.